<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>JSP+MyBatis显示所有用户</title>
    <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.css">
</head>
<body>
<h1 style="color: blue">所有用户</h1>
<table class="table table-responsive table-striped">
    <tr>
        <td>ID</td>
        <td>姓名</td>
        <td>密码</td>
        <td>性别</td>
        <td>出生日期</td>
        <td>注册日期</td>
    </tr>
    <c:forEach items="${requestScope.pageInfo.list}" var="user">
        <tr>
            <td>${user.id}</td>
            <td>${user.name}</td>
            <td>${user.password}</td>
            <td>${user.sex}</td>
            <td><fmt:formatDate value="${user.birthday}" pattern="yyyy年MM月dd日"/></td>
                <%-- 按指定的日期格式进行展示 --%>
            <td><fmt:formatDate value="${user.registTime}" pattern="yyyy年MM月dd日 HH:mm:ss"/> </td>
        </tr>
    </c:forEach>
</table>
<ul class="pagination">
    <c:if test="${requestScope.pageInfo.hasPreviousPage}">
        <li>
            <a href="${pageContext.request.contextPath}/userServlet?pageNum=${requestScope.pageInfo.prePage}">
                上一页
            </a>
        </li>
    </c:if>
    <c:forEach begin="1" end="${requestScope.pageInfo.pages}" var="p">
        <li>
            <a href="${pageContext.request.contextPath}/userServlet?pageNum=${p}">
                    ${p}
            </a>
        </li>
    </c:forEach>
    <c:if test="${requestScope.pageInfo.hasNextPage}">
        <li>
            <a href="${pageContext.request.contextPath}/userServlet?pageNum=${requestScope.pageInfo.nextPage}">
                下一页
            </a>
        </li>
    </c:if>
</ul>
</body>
</html>
